/**
 * @Title: stationController.java
 * @Package tt.dz.mvc.controller.sys
 * @author pengyu
 * @date 2015年12月17日 上午10:21:55
 * @version V1.0
 */
package tt.dz.mvc.controller.sys;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSON;
import tt.dz.dao.ext.charger.OmsChargerChargeBillRecordDao;
import tt.dz.dao.ext.charger.OmsChargerDao;
import tt.dz.dao.ext.charger.OmsChargerOfflineRecordDao;
import tt.dz.dao.ext.charger.OmsChargerStateAlternateDao;
import tt.dz.dao.ext.charger.OmsChargerStateDirectDao;
import tt.dz.entity.base.JsonCommon;
import tt.dz.entity.base.JsonForList;
import tt.dz.entity.charger.OmsCharger;
import tt.dz.entity.charger.OmsChargerNo;
import tt.dz.entity.charger.OmsChargerOfflineRecord;
import tt.dz.entity.charger.OmsChargerStateAlternate;
import tt.dz.entity.charger.OmsChargerStateDirect;
import tt.dz.entity.exception.BizException;
import tt.dz.entity.station.OmsStation;
import tt.dz.mvc.controller.base.BaseController;
import tt.dz.mvc.controller.middleware.ChargeController;
import tt.dz.service.imp.sys.ChargeDataUploadingVO;
import tt.dz.service.middleware.OmsBespeakService;
import tt.dz.service.middleware.OmsChargeService;
import tt.dz.service.middleware.SetService;
import tt.dz.service.sys.ChargerService;
import tt.dz.service.sys.OperStationService;
import tt.dz.service.sys.StationService;
import tt.dz.tcp.socket.exception.CreateConnectionFailException;
import tt.dz.tcp.socket.exception.RetryFailException;
import tt.dz.util.ActionUtils;
import tt.dz.util.ExcelExporter;
import tt.dz.util.OmsConstant;
import tt.dz.util.RedisClient;
import tt.dz.util.StringUtil;
import tt.dz.vo.oms.ChargerExportVO;

@Controller
public class ChargerController extends BaseController {
	private Log log = LogFactory.getLog(ChargeController.class);

	@Autowired
	ChargerService chargerService;
	@Autowired
	StationService stationService;
	@Autowired
	OperStationService omsOperStationService;
	@Autowired
	OmsBespeakService omsBespeakService;
	@Autowired
	OmsChargeService omsChargeService;//充电用的service
	@Resource
	OmsChargerStateDirectDao omsChargerStateDirectDao;
	@Resource
	OmsChargerChargeBillRecordDao omsChargerChargeBillRecordDao;
	@Resource
	OmsChargerDao omsChargerDao;
	@Resource
	OmsChargerStateAlternateDao omsChargerStateAlternateDao;
	@Resource
	OmsChargerOfflineRecordDao omsChargerOfflineRecordDao;
	@Autowired
	SetService setService;

	// 1.自营站点列表接口
	@SuppressWarnings("rawtypes")
	@RequestMapping("/getChargerList")
	@ResponseBody
	public JsonForList getChargerList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		JsonForList isLogin = StringUtil.isLogin(request);
		if(isLogin.getCode().equals("400")){
			return isLogin;
		}
//		HttpSession session = request.getSession(); 
//		String login_oper_id = (String) session.getAttribute("login_oper_id"); 
		OmsCharger charger = new OmsCharger();
		String charger_id = request.getParameter("charger_id");
		if(StringUtil.isNotBlank(charger_id)){
			 charger.setCharger_id(charger_id);
		}
		String station_id = request.getParameter("station_id");
		if(StringUtil.isNotBlank(station_id)){
			 charger.setStation_id(station_id);
		}
		/** 枪 端口例如12315 */
		String port = request.getParameter("port");
		if (StringUtils.isNumeric(port)) {
			charger.setPort(Integer.valueOf(port));
		}
		/** port_no 接口序号,从0开始;,3.0版本新增,对应充电口号 */
		String port_no = request.getParameter("port_no");
		if (StringUtils.isNumeric(port_no)) {
			charger.setPort_no(Integer.valueOf(port_no));
		}
		/** 二维码标识 */
		String qr_code = request.getParameter("qr_code");
		if(StringUtil.isNotBlank(qr_code)){
			 charger.setQr_code(qr_code);
		}
		/** 1--直流 2--交流 3--混合 */
		String charger_type= request.getParameter("charger_type");
		if (StringUtils.isNumeric(charger_type)) {
			charger.setCharger_type(Integer.valueOf(charger_type));
		}
		/** 接口数量 1：单枪、2：双枪 */
		String port_quantity = request.getParameter("port_quantity");
		if (StringUtils.isNumeric(port_quantity)) {
			charger.setPort_quantity(Integer.valueOf(port_quantity));
		}
		/** 充电接口类型：\r\n 1.国标；\r\n 2特斯拉；\r\n 3.ABB，\r\n 4其他 */
		String charge_port_type = request.getParameter("charge_port_type");
		if (StringUtils.isNumeric(charge_port_type)) {
			charger.setCharge_port_type(Integer.valueOf(charge_port_type));
		}
		/** 设备信息;GPRS桩专用 */
		String forward_srv_id = request.getParameter("forward_srv_id");
		if(StringUtil.isNotBlank(forward_srv_id)){
			 charger.setForward_srv_id(Integer.valueOf(forward_srv_id));
		}
		/** 充电运营服务商ID */
		String oper_merchant_id = request.getParameter("oper_merchant_id");
		if(StringUtil.isNotBlank(oper_merchant_id)){
			 charger.setOper_merchant_id(oper_merchant_id);
		}
		/** 0 不可用，1：可用 ;在线桩专用 */
		String wifi_ap = request.getParameter("wifi_ap");
		if (StringUtils.isNumeric(wifi_ap)) {
			charger.setWifi_ap(Integer.valueOf(wifi_ap));
		}
//		/** 安装时间 */
//		String installation_time = request.getParameter("installation_time");
//		if(StringUtil.isNotBlank(installation_time)){
//			charger.setInstallation_time(new Date(installation_time));
//		}
		
		/** GPRS信号卡号，由业务规则按一定规律生成 */
		String card_gprs = request.getParameter("card_gprs");
		if(StringUtil.isNotBlank(card_gprs)){
			 charger.setCard_gprs(card_gprs);
		}
		/** GPRS桩专用，由业务规则按一定规律生成 */
		String card_wifi = request.getParameter("card_wifi");
		if(StringUtil.isNotBlank(card_wifi)){
			 charger.setCard_wifi(card_wifi);
		}
		/** 所在地电桩桩号，由业务规则按一定规律生成 */
		String serial_no = request.getParameter("serial_no");
		if(StringUtil.isNotBlank(serial_no)){
			 charger.setSerial_no(serial_no);
		}
		/** 生产厂商 */
		String factory_id = request.getParameter("factory_id");
		if(StringUtil.isNotBlank(factory_id)){
			 charger.setFactory_id(factory_id);
		}
		/** 出厂序列号 */
		String dev_sn = request.getParameter("dev_sn");
		if(StringUtil.isNotBlank(dev_sn)){
			 charger.setDev_sn(dev_sn);
		}
		/** 软件版本 */
		String software_version = request.getParameter("software_version");
		if(StringUtil.isNotBlank(software_version)){
			 charger.setSoftware_version(software_version);
		}
		/** 城市代码 */
		String city_code = request.getParameter("city_code");
		if(StringUtil.isNotBlank(city_code)){
			 charger.setCity_code(city_code);
		}
		/** 备注：预留 */
		String charger_ip = request.getParameter("charger_ip");
		if(StringUtil.isNotBlank(charger_ip)){
			 charger.setCharger_ip(charger_ip);
		}
		/** 0-在线桩（GPRS桩）,1-离线桩（蓝牙桩） */
		String connect_type = request.getParameter("connect_type");
		if (StringUtils.isNumeric(connect_type)) {
			charger.setConnect_type(Integer.valueOf(connect_type));
		}
		/** 0 不加密 ;1 DES ;2 3DES; 3 AES;4 MD5 */
		String encrypt_type = request.getParameter("encrypt_type");
		if (StringUtils.isNumeric(encrypt_type)) {
			charger.setEncrypt_type(Integer.valueOf(encrypt_type));
		}
		String comm_key = request.getParameter("comm_key");
		if(StringUtil.isNotBlank(comm_key)){
			 charger.setComm_key(comm_key);
		}
		/** 0为未激活，1为已激活;蓝牙桩专用 */
		String active_flag = request.getParameter("active_flag");
		if (StringUtils.isNumeric(active_flag)) {
			charger.setActive_flag(Integer.valueOf(active_flag));
		}
		/** 蓝牙桩专用id */
		String ssid = request.getParameter("ssid");
		if(StringUtil.isNotBlank(ssid)){
			 charger.setSsid(ssid);
		}
		/** 协议名称 1：EV3C；2：Protocol Translate；3 P2P */
		String protocol_type = request.getParameter("protocol_type");
		if(StringUtil.isNotBlank(protocol_type)){
			 charger.setProtocol_type(protocol_type);
		}
		/** 通讯协议版本号 */
		String protocol_version = request.getParameter("protocol_version");
		if(StringUtil.isNotBlank(protocol_version)){
			 charger.setProtocol_version(protocol_version);
		}
		/*电费费率方案号 */
		String rate_schema_charge_fee = request.getParameter("rate_schema_charge_fee");
		if (StringUtils.isNumeric(rate_schema_charge_fee)) {
			charger.setRate_schema_charge_fee(Integer.valueOf(rate_schema_charge_fee));
		}
		/** 服务费费率方案号 */
		String rate_schema_service_fee = request.getParameter("rate_schema_service_fee");
		if (StringUtils.isNumeric(rate_schema_service_fee)) {
			charger.setRate_schema_service_fee(Integer.valueOf(rate_schema_service_fee));
		}
		/** 电费归属运营服务商ID */
		String fee_oper_merchant_id = request.getParameter("fee_oper_merchant_id");
		if(StringUtil.isNotBlank(fee_oper_merchant_id)){
			 charger.setFee_oper_merchant_id(fee_oper_merchant_id);
		}
//		/** 创建时间 */
//		Date create_time = request.getParameter("create_time");
//		/** 创建人ID，如果为0000000000为非真实数据。 */
//		String create_oper_id = request.getParameter("create_oper_id");
//		/** 更新时间 */
//		Date update_time = request.getParameter("update_time");
//		/** 更新人id */
//		String update_oper_id = request.getParameter("update_oper_id");
		String valid_flag = request.getParameter("valid_flag");
		if (StringUtils.isNumeric(valid_flag)) {
			charger.setValid_flag(Integer.valueOf(valid_flag));
		}
//		return chargerService.getChargerList(charger);
//		return "fghjm";
		return chargerService.getChargerListTest(charger);
	}
	
	// 通过站点ID查看桩以及桩的状态
	@SuppressWarnings("rawtypes")
	@RequestMapping("/getChargerListByStation")
	@ResponseBody
	public JsonForList getChargerListByStation(HttpServletRequest request, HttpServletResponse response) throws Exception {
		JsonForList isLogin = StringUtil.isLogin(request);
		if(isLogin!=null){
			return isLogin;
		}
//		HttpSession session = request.getSession(); 
//		String oper_id = (String) session.getAttribute("oper_id"); 
		OmsCharger charger = new OmsCharger();
		String station_id = request.getParameter("station_id");
		if(StringUtil.isNotBlank(station_id)){
			 charger.setStation_id(station_id);
		}
		return chargerService.getChargerListByStation(charger);
	}
		
	
	//11.添加电桩接口:对桩分配一个站id：如果桩是无站id的桩，则update桩（几个充电口就是几条数据）和update站里面桩的数量。
	//   如果桩是有站的桩，则update老站和新站里面桩的数量，同时update桩（几个充电口就是几条数据）
	@SuppressWarnings({ "rawtypes", "unused" })
	@RequestMapping("/addChargerToStation")
	@ResponseBody
	public JsonCommon addChargerToStation(HttpServletRequest request, HttpServletResponse response) throws Exception {
		JsonCommon json = new JsonCommon();
		OmsCharger charger_query = new OmsCharger();
		HttpSession session = request.getSession(); 
		String update_oper_id = (String) session.getAttribute("login_oper_id"); // 更新人id	
		String charger_id = request.getParameter("charger_id");
		String station_id = request.getParameter("station_id");
		if(StringUtil.isBlank(charger_id)||StringUtil.isBlank(station_id)){
			json.setCode("400");
			json.setMsg("charger_id or station_id null");
			return json;
		}
		charger_query.setCharger_id(charger_id);
		
		OmsCharger charger = chargerService.findOneExample(charger_query, null, null);
		if(charger==null){
			json.setCode("400");
			json.setMsg("charger_id not exist ");
			return json;
		}
		if(charger.getStation_id() != null  && charger.getStation_id().equals(station_id)){
			json.setCode("200");
			json.setMsg("addChargerToStation success ");
			return json;
		}
		OmsStation station_before = null;
		if(StringUtil.isNotBlank(charger.getStation_id())){//此桩之前有归属站
			station_before = stationService.getStationById(charger.getStation_id());
			if(station_before!=null){
				if(charger.getCharger_type()==1){//1--直流  2--交流  3--混合
					station_before.setDirect_num(station_before.getDirect_num() - 1);
				}else if(charger.getCharger_type()==2){
					station_before.setAlternate_num(station_before.getAlternate_num() - 1);
				}
				//站的桩的总数也要-1
				station_before.setTotal_charger(station_before.getAlternate_num()+station_before.getDirect_num());
				station_before.setUpdate_oper_id(update_oper_id);
				station_before.setUpdate_time(new Date());
				stationService.updateStation(station_before);
			}
		}
		charger.setStation_id(station_id);
		charger.setUpdate_oper_id(update_oper_id);
		charger.setUpdate_time(new Date());
		
		Lock lock = new ReentrantLock(); // 锁对象
		OmsStation station_after = stationService.getStationById(station_id);
		try {
			lock.lock();
			StringBuffer sql = new StringBuffer();
			sql.append("select IFNULL(CONVERT(max(serial_no*1),SIGNED),0) + 1 as serial_no from oms_charger WHERE station_id = " + station_id);
			List<Map<String, Object>> chargerList = new ArrayList<Map<String, Object>>();
			int serial_no = 0;
			chargerList = omsChargerDao.findDataBySql(sql.toString());
			String serialNo = chargerList.get(0).get("serial_no").toString();
			charger.setSerial_no(serialNo);
			charger.setStation_name(station_after.getStation_name());
			chargerService.updateCharger(charger);	
		} catch (Exception e) {
		} finally {
			lock.unlock();
		}
		
		if(station_after!=null){
			if(charger.getCharger_type()==1){//1--直流  2--交流  3--混合
				station_after.setDirect_num(station_after.getDirect_num() + 1);
			}else if(charger.getCharger_type()==2){
				station_after.setAlternate_num(station_after.getAlternate_num() + 1);
			}
			//站的桩的总数也要+1
			station_after.setTotal_charger(station_after.getAlternate_num()+station_after.getDirect_num());
			station_after.setUpdate_oper_id(update_oper_id);
			station_after.setUpdate_time(new Date());
			stationService.updateStation(station_after);
		}
		json.setCode("200");
		json.setMsg("addChargerToStation success ");
		return json;
	}
	
	//12.通过桩charger_id来查询桩以及对应站的名称。
	@SuppressWarnings("rawtypes")
	@RequestMapping("/getStationByChargerId")
	@ResponseBody
	public JsonCommon getStationByChargerId(HttpServletRequest request, HttpServletResponse response) throws Exception {
		JsonCommon json = new JsonCommon();
		HttpSession session = request.getSession(); 
		String update_oper_id = (String) session.getAttribute("login_oper_id"); // 更新人id	
		String charger_id = request.getParameter("charger_id");
		if(StringUtil.isBlank(charger_id)||StringUtil.isBlank(update_oper_id)){
			json.setCode("400");
			json.setMsg("charger_id or port_no or oper_id null");
			return json;
		}
		return stationService.getStationByChargerId(charger_id);
	}	
	
	//更新电桩
	@SuppressWarnings("rawtypes")
	@RequestMapping("/updateCharger")
	@ResponseBody
	public JsonForList updateCharger(HttpServletRequest request, HttpServletResponse response) throws Exception {
//		String code,msg,jsonStr;
		JsonForList json = new JsonForList();
//		OmsCharger charger_query = new OmsCharger();
		HttpSession session = request.getSession(); 
		String update_oper_id = (String) session.getAttribute("login_oper_id"); // 更新人id	
		String charger_id = request.getParameter("charger_id");
		String port_no = request.getParameter("port_no");
		if(StringUtil.isBlank(charger_id)||StringUtil.isBlank(update_oper_id)){
			json.setCode("400");
			json.setMsg("charger_id or oper_id null");
			return json;
		}
		//查询charger
//		charger_query.setCharger_id(charger_id);
//		charger_query.setPort_no(Integer.valueOf(port_no));
		int result = 0;
		List<OmsCharger> list = new ArrayList<OmsCharger>();
		OmsCharger omsCharger = new OmsCharger();
		omsCharger.setCharger_id(charger_id);
		list = chargerService.getList(omsCharger);
		for(OmsCharger charger : list){
			String station_id = request.getParameter("station_id");
			if(StringUtil.isNotBlank(station_id)){
				 charger.setStation_id(station_id);
			}
			/** 安装时间 */
			String installation_time = request.getParameter("installation_time");
			if(StringUtil.isNotBlank(installation_time)){
				SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
				charger.setInstallation_time(format.parse(installation_time));
			}
			/** 枪 端口例如12315 */
			String port = request.getParameter("port");
			if (StringUtils.isNumeric(port)) {
				charger.setPort(Integer.valueOf(port));
			}
			/** 二维码标识 */
			String qr_code = request.getParameter("qr_code");
			if(StringUtil.isNotBlank(qr_code)){
				 charger.setQr_code(qr_code);
			}
			/** 1--直流 2--交流 3--混合 */
			String charger_type= request.getParameter("charger_type");
			if (StringUtils.isNumeric(charger_type)) {
				charger.setCharger_type(Integer.valueOf(charger_type));
			}
			/** 接口数量 1：单枪、2：双枪 */
			String port_quantity = request.getParameter("port_quantity");
			if (StringUtils.isNumeric(port_quantity)) {
				charger.setPort_quantity(Integer.valueOf(port_quantity));
			}
			/** 充电接口类型：\r\n 1.国标；\r\n 2特斯拉；\r\n 3.ABB，\r\n 4其他 */
			String charge_port_type = request.getParameter("charge_port_type");
			if (StringUtils.isNumeric(charge_port_type)) {
				charger.setCharge_port_type(Integer.valueOf(charge_port_type));
			}
			/** 设备信息;GPRS桩专用 */
			String forward_srv_id = request.getParameter("forward_srv_id");
			if(StringUtil.isNotBlank(forward_srv_id)){
				charger.setForward_srv_id(Integer.valueOf(forward_srv_id));
			}
			/** 充电运营服务商ID */
			String oper_merchant_id = request.getParameter("oper_merchant_id");
			if(StringUtil.isNotBlank(oper_merchant_id)){
				 charger.setOper_merchant_id(oper_merchant_id);
			}
			/** 是否允许桩生成费用*/
			String is_allow_generate_fee = request.getParameter("is_allow_generate_fee");
			if(StringUtil.isNotBlank(is_allow_generate_fee)){
				 charger.setIs_allow_generate_fee(Integer.valueOf(is_allow_generate_fee));
			}
			/** 合作商类型 */
			String entity_type = request.getParameter("entity_type");
			if(StringUtil.isNotBlank(entity_type)){
				 charger.setEntity_type(entity_type);
			}
			
			
			/** 合作商ID */
			String entity_id = request.getParameter("entity_id");
			if(StringUtil.isNotBlank(entity_id)){
				 charger.setEntity_id(entity_id);
			}
			/** 0 不可用，1：可用 ;在线桩专用 */
			String wifi_ap = request.getParameter("wifi_ap");
			if (StringUtils.isNumeric(wifi_ap)) {
				charger.setWifi_ap(Integer.valueOf(wifi_ap));
			}
			/** 安装时间 */
//				Date installation_time = request.getParameter("installation_time");
			/** GPRS信号卡号，由业务规则按一定规律生成 */
			String card_gprs = request.getParameter("card_gprs");
			if(StringUtil.isNotBlank(card_gprs)){
				 charger.setCard_gprs(card_gprs);
			}
			/** GPRS桩专用，由业务规则按一定规律生成 */
			String card_wifi = request.getParameter("card_wifi");
			if(StringUtil.isNotBlank(card_wifi)){
				 charger.setCard_wifi(card_wifi);
			}
			/** 所在地电桩桩号，由业务规则按一定规律生成 */
			String serial_no = request.getParameter("serial_no");
			if(StringUtil.isNotBlank(serial_no)){
				 charger.setSerial_no(serial_no);
			}
			/** 生产厂商 */
			String factory_id = request.getParameter("factory_id");
			if(StringUtil.isNotBlank(factory_id)){
				 charger.setFactory_id(factory_id);
			}
			/** 出厂序列号 */
			String dev_sn = request.getParameter("dev_sn");
			if(StringUtil.isNotBlank(dev_sn)){
				 charger.setDev_sn(dev_sn);
			}
			/** 软件版本 */
			String software_version = request.getParameter("software_version");
			if(StringUtil.isNotBlank(software_version)){
				 charger.setSoftware_version(software_version);
			}
			/** 城市代码 */
			String city_code = request.getParameter("city_code");
			if(StringUtil.isNotBlank(city_code)){
				 charger.setCity_code(city_code);
			}
			/** 备注：预留 */
			String charger_ip = request.getParameter("charger_ip");
			if(StringUtil.isNotBlank(charger_ip)){
				 charger.setCharger_ip(charger_ip);
			}
			/** 0-在线桩（GPRS桩）,1-离线桩（蓝牙桩） */
			String connect_type = request.getParameter("connect_type");
			if (StringUtils.isNumeric(connect_type)) {
				charger.setConnect_type(Integer.valueOf(connect_type));
			}
			/** 0 不加密 ;1 DES ;2 3DES; 3 AES;4 MD5 */
			String encrypt_type = request.getParameter("encrypt_type");
			if (StringUtils.isNumeric(encrypt_type)) {
				charger.setEncrypt_type(Integer.valueOf(encrypt_type));
			}
			String comm_key = request.getParameter("comm_key");
			if(StringUtil.isNotBlank(comm_key)){
				 charger.setComm_key(comm_key);
			}
			/** 0为未激活，1为已激活;蓝牙桩专用 */
			String active_flag = request.getParameter("active_flag");
			if (StringUtils.isNumeric(active_flag)) {
				charger.setActive_flag(Integer.valueOf(active_flag));
			}
			/** 蓝牙桩专用id */
			String ssid = request.getParameter("ssid");
			if(StringUtil.isNotBlank(ssid)){
				 charger.setSsid(ssid);
			}
			/** 协议名称 1：EV3C；2：Protocol Translate；3 P2P */
			String protocol_type = request.getParameter("protocol_type");
			if(StringUtil.isNotBlank(protocol_type)){
				 charger.setProtocol_type(protocol_type);
			}
			/** 通讯协议版本号 */
			String protocol_version = request.getParameter("protocol_version");
			if(StringUtil.isNotBlank(protocol_version)){
				 charger.setProtocol_version(protocol_version);
			}
			/*电费费率方案号 */
			String rate_schema_charge_fee = request.getParameter("rate_schema_charge_fee");
			if (StringUtils.isNumeric(rate_schema_charge_fee)) {
				charger.setRate_schema_charge_fee(Integer.valueOf(rate_schema_charge_fee));
			}
			/** 服务费费率方案号 */
			String rate_schema_service_fee = request.getParameter("rate_schema_service_fee");
			if (StringUtils.isNumeric(rate_schema_service_fee)) {
				charger.setRate_schema_service_fee(Integer.valueOf(rate_schema_service_fee));
			}
			/** 电费归属运营服务商ID */
			String fee_oper_merchant_id = request.getParameter("fee_oper_merchant_id");
			if(StringUtil.isNotBlank(fee_oper_merchant_id)){
				 charger.setFee_oper_merchant_id(fee_oper_merchant_id);
			}
			charger.setUpdate_oper_id(update_oper_id);
			charger.setUpdate_time(new Date());
			chargerService.updateCharger(charger);	
		}
		JsonForList json1 = new JsonForList();
		json1.setCode("200");
		json1.setMsg("updateCharger success");
		return json1;
	}
	//
	@SuppressWarnings("rawtypes")
	@RequestMapping("/logicalDelCharger")
	@ResponseBody
	public JsonForList logicalDelCharger(HttpServletRequest request, HttpServletResponse response) throws Exception {
		JsonForList json = new JsonForList();
		HttpSession session = request.getSession(); 
		String update_oper_id = (String) session.getAttribute("login_oper_id"); // 更新人id	
		String chargerIds = request.getParameter("chargerIdList");
		String chargerType = request.getParameter("chargerType");
		if(StringUtil.isBlank(chargerIds)||StringUtil.isBlank(update_oper_id)||StringUtil.isBlank(chargerType)){
			json.setCode("400");
			json.setMsg("chargerIdList or oper_id or chargerType null");
			return json;
		}
		List<String> chargerIdList = JSON.parseArray(chargerIds,String.class);
		try {
			json = chargerService.deleteCharger(chargerIdList,update_oper_id,chargerType);
		} catch (Exception e) {
			json.setCode("400");
			json.setMsg(e.getMessage());
		}
		return json;
	}
//	//桩详情
//	@SuppressWarnings("rawtypes")
//	@RequestMapping("/getChargerDetail")
//	@ResponseBody
//	public JsonForList getChargerDetail(HttpServletRequest request, HttpServletResponse response) throws Exception {
//		JsonForList json = new JsonForList();
//		JsonForList isLogin = StringUtil.isLogin(request);
//		if(isLogin!=null){
//			return isLogin;
//		}
//		String charger_id = request.getParameter("charger_id");
////		String port_no = request.getParameter("port_no");
//		if(StringUtil.isBlank(charger_id)){
//			json.setCode("400");
//			json.setMsg("charger_id or port_no or oper_id null");
//			return json;
//		}
//		return chargerService.getChargerDetail(charger_id);
//	}
	//桩详情
	@SuppressWarnings("rawtypes")
	@RequestMapping("/getChargerDetail")
	@ResponseBody
	public JsonCommon getChargerDetail(HttpServletRequest request, HttpServletResponse response) throws Exception {
		JsonCommon json = new JsonCommon();
		String charger_id = request.getParameter("charger_id");
//		String port_no = request.getParameter("port_no");
		if(StringUtil.isBlank(charger_id)){
			json.setCode("400");
			json.setMsg("charger_id or port_no or oper_id null");
			return json;
		}
		return chargerService.getChargerDetail(charger_id);
	}
	@SuppressWarnings("rawtypes")
	@RequestMapping("/exportCharger")
//	@ResponseBody
	public void exportCharger(Integer chargerType, String chargerIds, HttpServletResponse response) throws Exception
	{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
		String fileName = String.format("oms_charger_%1$s.xls", sdf.format(new Date()));
		String[] list_chargerId = null;
		if(StringUtils.isNotEmpty(chargerIds))
			list_chargerId = chargerIds.split(",");
		List<ChargerExportVO> list = chargerService.getExportData(chargerType, list_chargerId);
		ExcelExporter excelExporter = new ExcelExporter();
		excelExporter.export(list, response, fileName);
	}
	
	@RequestMapping("/updateQrCodeFromOms")
	@ResponseBody
	public JsonCommon<String> updateQrCode(HttpServletRequest request, HttpServletResponse response) throws Exception {
		JsonCommon<String> json = new JsonCommon<String>();
		String charger_id = request.getParameter("charger_id");
		if(StringUtil.isBlank(charger_id)){
			json.setCode("400");
			json.setMsg("charger_id null");
			return json;
		}
		//通过前4位charger_id来查询qr_code
		String qrCode = chargerService.updateQrCode(charger_id);
		try
		{
			// 通知桩更新二维码
			Map<String, String> map = new HashMap<String, String>();
			map.put("chargerId", charger_id);
			map.put("qrCode", qrCode);
			setService.setQrCode(map);
		}
		catch (CreateConnectionFailException | RetryFailException e)
		{
			log.error(e.getMessage(), e);

		}
		
		json.setCode("200");
		json.setMsg("setQrCode success");
		json.setPojo(qrCode);
		return json;
	}

	@RequestMapping("/sendQrCode")
	@ResponseBody
	public JsonCommon<String> sendQrCode(String charger_id) throws RetryFailException, CreateConnectionFailException, BizException
	{
		JsonCommon<String> json = new JsonCommon<>();
		if (StringUtils.isEmpty(charger_id))
			throw new NullPointerException("charger_id is null");

		try
		{
			String qrCode = chargerService.getQrCode(charger_id);
			Map<String, String> map = new HashMap<String, String>();
			map.put("chargerId", charger_id);
			map.put("qrCode", qrCode);
			setService.setQrCode(map);
		}
		catch (CreateConnectionFailException | RetryFailException e)
		{
			log.error(e.getMessage(), e);
			throw e;
		}

		json.setCode("200");
		json.setMsg("sendQrCode success");
		return json;
	}

	//8.预约接口
	@RequestMapping("/bespeakFromOms")
	@ResponseBody
	public JsonCommon<String> bespeak(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String,String> map = StringUtil.getParameterByOms(request);
//		String portNo = request.getParameter("portNo");//AS传值
//		String chargerId = request.getParameter("chargerId");//AS传值
//		String userCard = request.getParameter("userCard");//AS传值
//		String bespeakMinute = request.getParameter("bespeakMinute");//AS传值  预约时长
//		return omsBespeakService.bespeak(chargerId,portNo,userCard,bespeakMinute);
		return omsBespeakService.bespeak(map);
//		return "sendSocket success";	}	
	}

	//9.消约接口
	@RequestMapping("/cancelBespeakFromOms") 
	@ResponseBody
	public JsonCommon<String> cancelBespeak(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String,String> map = StringUtil.getParameterByMiddle(request);
//		String chargerId = request.getParameter("chargerId");//AS传值
//		String portNo = request.getParameter("portNo");//AS传值
//		String userCard = request.getParameter("userCard");//AS传值
//		return omsBespeakService.cancelBespeak(chargerId,portNo,userCard);
		return omsBespeakService.cancelBespeak(map);
	}	
	//6.开启充电接口
	@RequestMapping("/startChargeFromOms") 
	@ResponseBody
	public JsonCommon<String> startCharge(HttpServletRequest request, HttpServletResponse response) throws Exception {
		//ev3c报文头
		String chargerId = request.getParameter("chargerId");
		//ev3c报文体
		String portNo = request.getParameter("portNo");
		String controlType = request.getParameter("controlType");
		String openRestrictedData = request.getParameter("openRestrictedData");//开启限制数据：不同充电模式下对应的计算量作为停机条件。自动充满停机方式下无意义。低字节在前，高字节在后。电量控制,单位为“度”，精确到0.01,传输数据放大100倍；时间控制，单位为“秒“，精确到1,；金额控制，单位为“元”，精确到0.01，传输数据放大100倍。
		//定时启动时间，分，时，日，月，对于即时充电，该时间无意义   例如：定时1月14日12时50分开始启动充电，则发送0x01,0x14, 0x12,0x50
		String startTime = request.getParameter("startTime");
		String userCard = request.getParameter("userCard");
		//充电数据上传间隔	BIN码	1		每两次充电数据上传间的间隔时间，单位：秒
		String charging_data_upload_interval = request.getParameter("charging_data_upload_interval");
		//电池详情上传间隔  每两次电池详情上传间的间隔时间，单位：秒
		String battery_details_upload_interval = request.getParameter("battery_details_upload_interval");
		Map<String,String> map  = new HashMap<String,String>();
		map.put("chargerId", chargerId);
		map.put("portNo",portNo);
		map.put("controlType",controlType);
		map.put("openRestrictedData",openRestrictedData);
		map.put("startTime",startTime);
		map.put("userCard",userCard);
		map.put("charging_data_upload_interval",charging_data_upload_interval);
		map.put("battery_details_upload_interval",battery_details_upload_interval);
//		return omsChargeService.startCharge(chargerId, userCard);
		omsChargeService.startCharge(map);
		JsonCommon<String> json = new JsonCommon<String>();
		json.setCode("200");
		json.setMsg(chargerId+" "+userCard+"stopCharge sendSocket success");
		return json;
	}	
	//7.关闭充电接口
	@RequestMapping("/stopChargeFromOms") 
	@ResponseBody
	public JsonCommon<String> stopCharge(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String responseMsgHeader,responseMsgBody;
		String chargerId = request.getParameter("chargerId");//AS传值
		String userCard = request.getParameter("userCard");//AS传值		
		String portNo = request.getParameter("portNo");//00 或者 01或者02
//		String code_type = "12";
		String control_type = "04";
		responseMsgBody = portNo+control_type+userCard;
		responseMsgHeader ="68"+StringUtil.complement(String.valueOf(responseMsgBody.length()), 4)+"01"+"000000"+"0001"+chargerId+"12"+StringUtil.now14time();
		StringUtil.sendSocket(responseMsgHeader+responseMsgBody);
		JsonCommon<String> json = new JsonCommon<String>();
		json.setCode("200");
		json.setMsg(chargerId+" "+userCard+"stopCharge sendSocket success");
		json.setPojo(responseMsgHeader+responseMsgBody);
		return json;
	}		
	
	//按桩类型查询某种类型桩的全部数量、空闲、充电中、预约中、离线中数量      设备电流类型:1--直流  2--交流  3--混合
	@RequestMapping("/getChargerStatusNo") 
	@ResponseBody
	public JsonCommon<OmsChargerNo> getChargerStatusNo(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String charger_type = request.getParameter("charger_type");
		return chargerService.getChargerStatusNo(charger_type);
	}
	
	//按桩类型查询包括桩表简单信息列表：返回数据：桩id 二维码 桩类型 桩序号 站点名 站点所在地   每个充电口状态：三个传入参数互斥，都传时以stationId > chargerType > chargerId
	@RequestMapping("/getSimpleChargerList") 
	@ResponseBody
	public JsonForList<Map<String, Object>> getSimpleChargerList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String chargerId = request.getParameter("chargerId");
		String charger_type = request.getParameter("chargerType");
		String stationId = request.getParameter("stationId");
		return chargerService.getSimpleChargerList(stationId,charger_type,chargerId);
	}	
	
	//实现分页
	//按桩类型查询包括桩表简单信息列表：返回数据：桩id 二维码 桩类型 桩序号 站点名 站点所在地   每个充电口状态：三个传入参数互斥，都传时以stationId > chargerType > chargerId
	@RequestMapping("/getSimpleChargerPageList") 
	@ResponseBody
	public JsonForList<Map<String, Object>> getSimpleChargerPageList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String chargerId = request.getParameter("chargerId");
		String charger_type = request.getParameter("chargerType");
		String stationId = request.getParameter("stationId");
		String chargerStatus = request.getParameter("chargerStatus");
		String searchStr = request.getParameter("searchStr");
		if (StringUtil.isNotBlank(searchStr)) {
        	searchStr = new String(searchStr.getBytes("iso-8859-1"),"utf-8");
		}
		return chargerService.getSimpleChargerPageList(ActionUtils.buildQueryParam(request, true),stationId,charger_type,chargerId,chargerStatus,searchStr);
	}
		
	//按桩类型、桩地址、桩状态查询桩详情···包括桩表信息、每个充电口状态
	@RequestMapping("/getChargerStatusList") 
	@ResponseBody
	public JsonForList<Map<String, Object>> getChargerStatusList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String chargerId = request.getParameter("chargerId");
		String charge_status = request.getParameter("status");
		String charger_type = request.getParameter("charger_type");
		String stationId = request.getParameter("stationId");
		return chargerService.getChargerStatusList(chargerId,charge_status,charger_type,stationId);
	}
	
	
	//根据运营商选择未分配站的桩
	@RequestMapping("/getChargersWithOutStationByOperMerchantId") 
	@ResponseBody
	public JsonForList<OmsCharger> getChargersWithOutStationByOperMerchantId(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String oper_merchant_id = request.getParameter("oper_merchant_id");
		if(StringUtil.isBlank(oper_merchant_id)){
			return new JsonForList<>(null, OmsConstant.ErrorCodeEnum.MissParam.value(), OmsConstant.ErrorCodeEnum.MissParam.desc());
		}
		return chargerService.getChargersWithOutStationByOperMerchantId(oper_merchant_id);
	}
	
	
	//根据站ID查询该站下面的桩列表及状态详情，包括桩充电口状态
	@RequestMapping("/getChargersDetailByStationId") 
	@ResponseBody
	public JsonForList getChargersDetailByStationId(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String station_id = request.getParameter("stationId");
		if(StringUtil.isBlank(station_id)){
			return new JsonForList<>(null, OmsConstant.ErrorCodeEnum.MissParam.value(), OmsConstant.ErrorCodeEnum.MissParam.desc());
		}
		return chargerService.getChargersDetailByStationId(station_id);
	}
	
//	//大屏单桩页 参数：站ID  必传   显示结果：年月日时分秒 星期几（前端实现） 
//	//返回结果：天气 温度 PM2.5 PM质量（好良差） 电压 功率  电流 SOC 预约用户卡号   充电枪口   已充电量  预计剩余时间  电池温度  
//	@SuppressWarnings("rawtypes")
//	@RequestMapping("/getBigScreenByChargerId")
//	@ResponseBody
//	public JsonCommon getBigScreenByChargerId(String charger_id) throws Exception
//	{
////		String charger_id = request.getParameter("charger_id");
//		if (StringUtils.isEmpty(charger_id))
//		{
//			return new JsonCommon(OmsConstant.ErrorCodeEnum.MissParam.value(), OmsConstant.ErrorCodeEnum.MissParam.desc());
//		}
//		OmsCharger charger = omsChargerDao.findOneExample(new OmsCharger(charger_id), null, null);
//		if (charger == null || charger.getCharger_type() == null)
//		{
//			return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
//		}
//
//		ScreenCharger sc = new ScreenCharger();
////		sc.setCharger_id(StringUtil.isBlank(charger_id) ? "0051123412341234" : charger_id);
//		switch (charger.getCharger_type())
//		{//1直流 2 交流
//			case 1:
//				//查询  6.12电池信息上送（可选）当前荷电状态	BIN码	1	系数为1%	0-100%  从redis中取得
//				OmsChargerStateDirect direct_query = new OmsChargerStateDirect();
//				direct_query.setCharger_id(charger_id);
//				//肯定是直流桩，所以查询  oms_charger_state_direct[直流充电桩状态表]
//				List<OmsChargerStateDirect> list_direct = omsChargerStateDirectDao.findExample(direct_query, null, null, null, null);
//				if (list_direct == null || list_direct.size() == 0)
//				{
//					return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
//				}
//				// 电压 功率  电流  SOC 从redis中取得
//				//list.size() = 2 是预期查询结果
//				//已充电量 预计剩余时间  从6.10充电状态上送  中取得；     最高动力电池温度	BIN码	1	系数为1   偏移50	-50到200度  从 6.12电池信息上送（可选） 中取得
//				//电压 功率  电流  SOC 从从6.10充电状态上送  中取得；
//				for (OmsChargerStateDirect state :  list_direct)
//				{
//					if (state.getCharge_status() == 2)
//					{
//						String oms_msg_charge_jrnl = "";
//						String battery_temperature = "";//温度
//						//查询当前最新的充电流水号，通过charger_id端口号
//						int port_no = state.getPort_no();
//
//						String key_charging = charger_id + String.format("%02d", port_no) + "_status";
//						Jedis redisClient = RedisClient.getConnect();
//
//						String json = redisClient.get(key_charging);
//						ChargeDataUploadingVO charging_vo = JSON.parseObject(json, ChargeDataUploadingVO.class);
//						redisClient.close();
//						if (charging_vo != null)
//						{
//							state.setSoc(charging_vo.getSoc());
//							state.setCharger_kwh(Float.valueOf(charging_vo.getCharger_kwh()));
//							state.setCharger_v(Float.valueOf(charging_vo.getCharger_v()));
//							state.setCharger_i(Float.valueOf(charging_vo.getCharger_i()));
//							state.setCharger_p(Float.valueOf(charging_vo.getCharger_p()));
//							BigDecimal r = new BigDecimal(charging_vo.getRemaining_time());
//							state.setRemaining_time(r.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
//							state.setSoc(charging_vo.getSoc());
//							BigDecimal temperature = new BigDecimal(charging_vo.getHighestTemperature());
//							state.setBattery_temperature(temperature.setScale(1, BigDecimal.ROUND_HALF_UP).toString());
//						}
//
//						/*
//						//取得电池组的最高温度
//						String key = oms_msg_charge_jrnl + "_batteryInfo";
//						String str_json = RedisClient.get(key);
//						if (StringUtil.isNotBlank(str_json))
//						{
//							BatteryInfoUploadVO vo = new BatteryInfoUploadVO();
//							vo = (BatteryInfoUploadVO) JSON.parse(str_json);
//							List<String> list_redis_uploadBattery = vo.getBatteryTemperatures();
//							float max_battery_temperature = 0.0f;
//							if (list_redis_uploadBattery.size() > 0)
//							{
//								for (String str : list_redis_uploadBattery)
//								{
//									if (Float.compare(max_battery_temperature, Float.parseFloat(str)) > 0)
//									{
//										max_battery_temperature = Float.parseFloat(str);
//									}
//								}
//								battery_temperature = String.valueOf(max_battery_temperature);
//							}
//							else
//							{
//								battery_temperature = "0.0";
//							}
//							list_direct.get(i).setBattery_temperature(battery_temperature);
//						}
//						*/
//					}
//				}
//				sc.setStateList(list_direct);
//				break;
//			case 2:
//				//查询  6.12电池信息上送（可选）当前荷电状态	BIN码	1	系数为1%	0-100%  从redis中取得
//				OmsChargerStateAlternate alternate_query = new OmsChargerStateAlternate();
//				alternate_query.setCharger_id(charger_id);
//				//肯定是直流桩，所以查询  oms_charger_state_direct[直流充电桩状态表]
//				List<OmsChargerStateAlternate> list_alternate = omsChargerStateAlternateDao.findExample(alternate_query, null, null, null, null);
//				if (list_alternate == null || list_alternate.size() == 0)
//				{
//					return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
//				}
//				// 电压 功率  电流  SOC 从redis中取得
//				//list.size() = 2 是预期查询结果
//				//已充电量 预计剩余时间  从6.10充电状态上送  中取得；     最高动力电池温度	BIN码	1	系数为1   偏移50	-50到200度  从 6.12电池信息上送（可选） 中取得
//				//电压 功率  电流  SOC 从从6.10充电状态上送  中取得；
//				for (OmsChargerStateAlternate state : list_alternate)
//				{
//					if (state.getCharge_status() == 2)
//					{
//						String oms_msg_charge_jrnl = "";
//						String battery_temperature = "";//温度
//
//						//查询当前最新的充电流水号，通过charger_id端口号
//						int port_no = state.getPort_no();
//
//						String key_charging = charger_id + String.format("%02d", port_no) + "_status";
//						Jedis redisClient = RedisClient.getConnect();
//
//						String json = redisClient.get(key_charging);
//						ChargeDataUploadingVO charging_vo = JSON.parseObject(json, ChargeDataUploadingVO.class);
//						redisClient.close();
//						if (charging_vo != null)
//						{
//							state.setSoc(charging_vo.getSoc());
//							state.setCharger_kwh(Float.valueOf(charging_vo.getCharger_kwh()));
//							state.setCharger_v(Float.valueOf(charging_vo.getCharger_v()));
//							state.setCharger_i(Float.valueOf(charging_vo.getCharger_i()));
//							state.setCharger_p(Float.valueOf(charging_vo.getCharger_p()));
//							BigDecimal r = new BigDecimal(charging_vo.getRemaining_time());
//							state.setRemaining_time(r.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
//							state.setRemaining_time(charging_vo.getRemaining_time());
//						}
//						;
//
//						/*
//						//取得电池组的最高温度
//						String key = oms_msg_charge_jrnl + "_batteryInfo";
//						String str_json = RedisClient.get(key);
//						if (StringUtil.isNotBlank(str_json))
//						{
//							BatteryInfoUploadVO vo = new BatteryInfoUploadVO();
//							vo = (BatteryInfoUploadVO) JSON.parse(str_json);
//							List<String> list_redis_uploadBattery = vo.getBatteryTemperatures();
//							float max_battery_temperature = 0.0f;
//							if (list_redis_uploadBattery.size() > 0)
//							{
//								for (String str : list_redis_uploadBattery)
//								{
//									if (Float.compare(max_battery_temperature, Float.parseFloat(str)) > 0)
//									{
//										max_battery_temperature = Float.parseFloat(str);
//									}
//								}
//								battery_temperature = String.valueOf(max_battery_temperature);
//							}
//							else
//							{
//								battery_temperature = "0.0";
//							}
//							list_alternate.get(i).setBattery_temperature(battery_temperature);
//						}
//						*/
//					}
//				}
//				sc.setStateList(list_alternate);
//				break;
//			default:
//				return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
//		}
//
//		//以下是天气信息		
//		//首先查询redis
//		String key = "baidu_weather";
//		String weather = "", city_temperature = "", pm25 = "", pm_level = "";
//		Map<String, String> map_fromRedis = RedisClient.getMap(key);
//		if (!map_fromRedis.isEmpty())
//		{
//			weather = map_fromRedis.get("weather");
//			city_temperature = map_fromRedis.get("city_temperature");
//			pm25 = map_fromRedis.get("pm25");
//			pm_level = map_fromRedis.get("pm_level");
//		}
//		else
//		{
//			String httpUrl = "http://apis.baidu.com/heweather/weather/free";
//			String httpArg = "cityid=CN101260101";//cityid=    city=guiyang
//			String jsonResult = request(httpUrl, httpArg);
//
//			JSONObject json = (JSONObject) JSON.parse(jsonResult);
//			JSONArray heWeather_data_array = json.getJSONArray("HeWeather data service 3.0");
//			JSONObject daily_forecast_object = heWeather_data_array.getJSONObject(0);
//			//{"wind":{"dir":"东风","deg":"142","sc":"4-5","spd":"21"},"hum":"75","fl":"18","pcpn":"0","tmp":"17",
//			//"pres":"1011","cond":{"code":"101","txt":"多云"},"vis":"10"}
//			JSONObject now_object = daily_forecast_object.getJSONObject("now");
//			city_temperature = now_object.get("tmp").toString();
//			JSONObject cond_object = now_object.getJSONObject("cond");
//			weather = cond_object.get("txt").toString();
//			//{"city":{"co":"1","so2":"8","o3":"76","no2":"31","aqi":"64","pm10":"75","pm25":"33","qlty":"良"}}
//			JSONObject aqi_object = daily_forecast_object.getJSONObject("aqi");
//			JSONObject city_object = aqi_object.getJSONObject("city");
//			pm25 = city_object.get("pm25").toString();
//			pm_level = city_object.get("qlty").toString();
//
//			Map<String, String> map = new HashMap<String, String>();
//			map.put("weather", weather);
//			map.put("city_temperature", city_temperature);
//			map.put("pm25", pm25);
//			map.put("pm_level", pm_level);
//			RedisClient.putMap(key, map);
//			RedisClient.expire(key, 60 * 60);
//		}
//		sc.setWeather(weather);
//		sc.setCity_temperature(city_temperature);
//		sc.setPm25(pm25);
//		sc.setPm_level(pm_level);
//
//		return new JsonCommon(sc, OmsConstant.SuccessCodeEnum.SuccessCode.value(), OmsConstant.SuccessCodeEnum.SuccessCode.desc());
//	}

	
	
/*	
	//大屏单桩页 参数：站ID  必传   显示结果：年月日时分秒 星期几（前端实现） 
	//返回结果：天气 温度 PM2.5 PM质量（好良差） 电压 功率  电流 SOC 预约用户卡号   充电枪口   已充电量  预计剩余时间  电池温度  
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping("/getBigScreenByChargerId")
	@ResponseBody
	public JsonCommon getBigScreenByChargerId(String charger_id_1,String charger_id_2) throws Exception
	{
		List stateList = new ArrayList<>();
//		String charger_id = request.getParameter("charger_id");
		if (StringUtils.isEmpty(charger_id_1)||(StringUtils.isEmpty(charger_id_2)))
		{
			return new JsonCommon(OmsConstant.ErrorCodeEnum.MissParam.value(), OmsConstant.ErrorCodeEnum.MissParam.desc());
		}
		OmsCharger charger_1 = omsChargerDao.findOneExample(new OmsCharger(charger_id_1), null, null);
		OmsCharger charger_2 = omsChargerDao.findOneExample(new OmsCharger(charger_id_2), null, null);
		if (charger_1 == null || charger_1.getCharger_type() == null || charger_2 == null || charger_2.getCharger_type() == null)
		{
			return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
		}
		ScreenCharger sc = new ScreenCharger();
//		sc.setCharger_id(StringUtil.isBlank(charger_id) ? "0051123412341234" : charger_id);
		switch (charger_1.getCharger_type())
		{//1直流 2 交流
			case 1:
				//查询  6.12电池信息上送（可选）当前荷电状态	BIN码	1	系数为1%	0-100%  从redis中取得
				OmsChargerStateDirect direct_query = new OmsChargerStateDirect();
				direct_query.setCharger_id(charger_id_1);
				//肯定是直流桩，所以查询  oms_charger_state_direct[直流充电桩状态表]
				List<OmsChargerStateDirect> list_direct = omsChargerStateDirectDao.findExample(direct_query, null, null, null, null);
				if (list_direct == null || list_direct.size() == 0)
				{
					return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
				}
				// 电压 功率  电流  SOC 从redis中取得
				//list.size() = 2 是预期查询结果
				//已充电量 预计剩余时间  从6.10充电状态上送  中取得；     最高动力电池温度	BIN码	1	系数为1   偏移50	-50到200度  从 6.12电池信息上送（可选） 中取得
				//电压 功率  电流  SOC 从从6.10充电状态上送  中取得；
				for (OmsChargerStateDirect state :  list_direct)
				{
					if (state.getCharge_status() == 2)
					{
						String oms_msg_charge_jrnl = "";
						String battery_temperature = "";//温度
						//查询当前最新的充电流水号，通过charger_id端口号
						int port_no = state.getPort_no();

						String key_charging = charger_id_1 + String.format("%02d", port_no) + "_status";
						Jedis redisClient = RedisClient.getConnect();

						String json = redisClient.get(key_charging);
						ChargeDataUploadingVO charging_vo = JSON.parseObject(json, ChargeDataUploadingVO.class);
						redisClient.close();
						if (charging_vo != null)
						{
							state.setSoc(charging_vo.getSoc());
							state.setCharger_kwh(Float.valueOf(charging_vo.getCharger_kwh()));
							state.setCharger_v(Float.valueOf(charging_vo.getCharger_v()));
							state.setCharger_i(Float.valueOf(charging_vo.getCharger_i()));
							state.setCharger_p(Float.valueOf(charging_vo.getCharger_p()));
							BigDecimal r = new BigDecimal(charging_vo.getRemaining_time());
							state.setRemaining_time(r.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
							state.setSoc(charging_vo.getSoc());
							BigDecimal temperature = new BigDecimal(charging_vo.getHighestTemperature());
							state.setBattery_temperature(temperature.setScale(1, BigDecimal.ROUND_HALF_UP).toString());
							stateList.add(state);
						}
					}
				}
//				sc.setStateList(list_direct);
				break;
			case 2:
				//查询  6.12电池信息上送（可选）当前荷电状态	BIN码	1	系数为1%	0-100%  从redis中取得
				OmsChargerStateAlternate alternate_query = new OmsChargerStateAlternate();
				alternate_query.setCharger_id(charger_id_1);
				//肯定是直流桩，所以查询  oms_charger_state_direct[直流充电桩状态表]
				List<OmsChargerStateAlternate> list_alternate = omsChargerStateAlternateDao.findExample(alternate_query, null, null, null, null);
				if (list_alternate == null || list_alternate.size() == 0)
				{
					return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
				}
				// 电压 功率  电流  SOC 从redis中取得
				//list.size() = 2 是预期查询结果
				//已充电量 预计剩余时间  从6.10充电状态上送  中取得；     最高动力电池温度	BIN码	1	系数为1   偏移50	-50到200度  从 6.12电池信息上送（可选） 中取得
				//电压 功率  电流  SOC 从从6.10充电状态上送  中取得；
				for (OmsChargerStateAlternate state : list_alternate)
				{
					if (state.getCharge_status() == 2)
					{
						String oms_msg_charge_jrnl = "";
						String battery_temperature = "";//温度

						//查询当前最新的充电流水号，通过charger_id端口号
						int port_no = state.getPort_no();

						String key_charging = charger_id_1 + String.format("%02d", port_no) + "_status";
						Jedis redisClient = RedisClient.getConnect();

						String json = redisClient.get(key_charging);
						ChargeDataUploadingVO charging_vo = JSON.parseObject(json, ChargeDataUploadingVO.class);
						redisClient.close();
						if (charging_vo != null)
						{
							state.setSoc(charging_vo.getSoc());
							state.setCharger_kwh(Float.valueOf(charging_vo.getCharger_kwh()));
							state.setCharger_v(Float.valueOf(charging_vo.getCharger_v()));
							state.setCharger_i(Float.valueOf(charging_vo.getCharger_i()));
							state.setCharger_p(Float.valueOf(charging_vo.getCharger_p()));
							BigDecimal r = new BigDecimal(charging_vo.getRemaining_time());
							state.setRemaining_time(r.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
							state.setRemaining_time(charging_vo.getRemaining_time());
							stateList.add(state);
						}
					}
				}
//				sc.setStateList(list_alternate);
				break;
			default:
				return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
		}
		
		switch (charger_2.getCharger_type())
		{//1直流 2 交流
			case 1:
				//查询  6.12电池信息上送（可选）当前荷电状态	BIN码	1	系数为1%	0-100%  从redis中取得
				OmsChargerStateDirect direct_query = new OmsChargerStateDirect();
				direct_query.setCharger_id(charger_id_2);
				//肯定是直流桩，所以查询  oms_charger_state_direct[直流充电桩状态表]
				List<OmsChargerStateDirect> list_direct = omsChargerStateDirectDao.findExample(direct_query, null, null, null, null);
				if (list_direct == null || list_direct.size() == 0)
				{
					return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
				}
				// 电压 功率  电流  SOC 从redis中取得
				//list.size() = 2 是预期查询结果
				//已充电量 预计剩余时间  从6.10充电状态上送  中取得；     最高动力电池温度	BIN码	1	系数为1   偏移50	-50到200度  从 6.12电池信息上送（可选） 中取得
				//电压 功率  电流  SOC 从从6.10充电状态上送  中取得；
				for (OmsChargerStateDirect state :  list_direct)
				{
					if (state.getCharge_status() == 2)
					{
						String oms_msg_charge_jrnl = "";
						String battery_temperature = "";//温度
						//查询当前最新的充电流水号，通过charger_id端口号
						int port_no = state.getPort_no();

						String key_charging = charger_id_2 + String.format("%02d", port_no) + "_status";
						Jedis redisClient = RedisClient.getConnect();

						String json = redisClient.get(key_charging);
						ChargeDataUploadingVO charging_vo = JSON.parseObject(json, ChargeDataUploadingVO.class);
						redisClient.close();
						if (charging_vo != null)
						{
							state.setSoc(charging_vo.getSoc());
							state.setCharger_kwh(Float.valueOf(charging_vo.getCharger_kwh()));
							state.setCharger_v(Float.valueOf(charging_vo.getCharger_v()));
							state.setCharger_i(Float.valueOf(charging_vo.getCharger_i()));
							state.setCharger_p(Float.valueOf(charging_vo.getCharger_p()));
							BigDecimal r = new BigDecimal(charging_vo.getRemaining_time());
							state.setRemaining_time(r.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
							state.setSoc(charging_vo.getSoc());
							BigDecimal temperature = new BigDecimal(charging_vo.getHighestTemperature());
							state.setBattery_temperature(temperature.setScale(1, BigDecimal.ROUND_HALF_UP).toString());
							stateList.add(state);
						}
					}
				}
//				sc.setStateList(list_direct);
				break;
			case 2:
				//查询  6.12电池信息上送（可选）当前荷电状态	BIN码	1	系数为1%	0-100%  从redis中取得
				OmsChargerStateAlternate alternate_query = new OmsChargerStateAlternate();
				alternate_query.setCharger_id(charger_id_2);
				//肯定是直流桩，所以查询  oms_charger_state_direct[直流充电桩状态表]
				List<OmsChargerStateAlternate> list_alternate = omsChargerStateAlternateDao.findExample(alternate_query, null, null, null, null);
				if (list_alternate == null || list_alternate.size() == 0)
				{
					return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
				}
				// 电压 功率  电流  SOC 从redis中取得
				//list.size() = 2 是预期查询结果
				//已充电量 预计剩余时间  从6.10充电状态上送  中取得；     最高动力电池温度	BIN码	1	系数为1   偏移50	-50到200度  从 6.12电池信息上送（可选） 中取得
				//电压 功率  电流  SOC 从从6.10充电状态上送  中取得；
				for (OmsChargerStateAlternate state : list_alternate)
				{
					if (state.getCharge_status() == 2)
					{
						String oms_msg_charge_jrnl = "";
						String battery_temperature = "";//温度

						//查询当前最新的充电流水号，通过charger_id端口号
						int port_no = state.getPort_no();

						String key_charging = charger_id_2 + String.format("%02d", port_no) + "_status";
						Jedis redisClient = RedisClient.getConnect();

						String json = redisClient.get(key_charging);
						ChargeDataUploadingVO charging_vo = JSON.parseObject(json, ChargeDataUploadingVO.class);
						redisClient.close();
						if (charging_vo != null)
						{
							state.setSoc(charging_vo.getSoc());
							state.setCharger_kwh(Float.valueOf(charging_vo.getCharger_kwh()));
							state.setCharger_v(Float.valueOf(charging_vo.getCharger_v()));
							state.setCharger_i(Float.valueOf(charging_vo.getCharger_i()));
							state.setCharger_p(Float.valueOf(charging_vo.getCharger_p()));
							BigDecimal r = new BigDecimal(charging_vo.getRemaining_time());
							state.setRemaining_time(r.setScale(0, BigDecimal.ROUND_HALF_UP).toString());
							state.setRemaining_time(charging_vo.getRemaining_time());
							stateList.add(state);
						}
					}
				}
//				sc.setStateList(list_alternate);
				break;
			default:
				return new JsonCommon(OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
		}
		
		sc.setStateList(stateList);
		
		
		//以下是天气信息		
		//首先查询redis
		String key = "baidu_weather";
		String weather = "", city_temperature = "", pm25 = "", pm_level = "";
		Map<String, String> map_fromRedis = RedisClient.getMap(key);
		if (!map_fromRedis.isEmpty())
		{
			weather = map_fromRedis.get("weather");
			city_temperature = map_fromRedis.get("city_temperature");
			pm25 = map_fromRedis.get("pm25");
			pm_level = map_fromRedis.get("pm_level");
		}
		else
		{
			String httpUrl = "http://apis.baidu.com/heweather/weather/free";
			String httpArg = "cityid=CN101260101";//cityid=    city=guiyang
			String jsonResult = request(httpUrl, httpArg);

			JSONObject json = (JSONObject) JSON.parse(jsonResult);
			JSONArray heWeather_data_array = json.getJSONArray("HeWeather data service 3.0");
			JSONObject daily_forecast_object = heWeather_data_array.getJSONObject(0);
			//{"wind":{"dir":"东风","deg":"142","sc":"4-5","spd":"21"},"hum":"75","fl":"18","pcpn":"0","tmp":"17",
			//"pres":"1011","cond":{"code":"101","txt":"多云"},"vis":"10"}
			JSONObject now_object = daily_forecast_object.getJSONObject("now");
			city_temperature = now_object.get("tmp").toString();
			JSONObject cond_object = now_object.getJSONObject("cond");
			weather = cond_object.get("txt").toString();
			//{"city":{"co":"1","so2":"8","o3":"76","no2":"31","aqi":"64","pm10":"75","pm25":"33","qlty":"良"}}
			JSONObject aqi_object = daily_forecast_object.getJSONObject("aqi");
			JSONObject city_object = aqi_object.getJSONObject("city");
			pm25 = city_object.get("pm25").toString();
			pm_level = city_object.get("qlty").toString();

			Map<String, String> map = new HashMap<String, String>();
			map.put("weather", weather);
			map.put("city_temperature", city_temperature);
			map.put("pm25", pm25);
			map.put("pm_level", pm_level);
			RedisClient.putMap(key, map);
			RedisClient.expire(key, 60 * 60);
		}
		sc.setWeather(weather);
		sc.setCity_temperature(city_temperature);
		sc.setPm25(pm25);
		sc.setPm_level(pm_level);

		return new JsonCommon(sc, OmsConstant.SuccessCodeEnum.SuccessCode.value(), OmsConstant.SuccessCodeEnum.SuccessCode.desc());
	}	
*/	

	
	//大屏单桩页 参数：站ID  必传   显示结果：年月日时分秒 星期几（前端实现） 
	//返回结果：天气 温度 PM2.5 PM质量（好良差） 电压 功率  电流 SOC 预约用户卡号   充电枪口   已充电量  预计剩余时间  电池温度  
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping("/getBigScreenByChargerId")
	@ResponseBody
	public JsonCommon getBigScreenByChargerId(String charger_id_1,String charger_id_2) throws Exception
	{
		if (StringUtils.isEmpty(charger_id_1)||(StringUtils.isEmpty(charger_id_2)))
		{
			return new JsonCommon(OmsConstant.ErrorCodeEnum.MissParam.value(), OmsConstant.ErrorCodeEnum.MissParam.desc());
		}
		
		String chargerIds = charger_id_1 + "," + charger_id_2;
		return chargerService.getChargeStateForBigScreenByIds(chargerIds);
	}
	
	//返回结果：天气 温度 PM2.5 PM质量（好良差） 
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping("/getWeatherByCityId")
	@ResponseBody
	public JsonCommon getWeatherByCityId(HttpServletRequest request, HttpServletResponse response) throws Exception
	{    
	    String cityId = request.getParameter("cityId");
		if (StringUtils.isEmpty(cityId))
		{
			return new JsonCommon(OmsConstant.ErrorCodeEnum.MissParam.value(), OmsConstant.ErrorCodeEnum.MissParam.desc());
		}
		
		return chargerService.getWeatherByCityId(cityId);
	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping("/getChargerStatusByStationId")
	@ResponseBody
	public JsonForList getChargerStatusByStationId(HttpServletRequest request, HttpServletResponse response) throws Exception
	{   
		String stationId = request.getParameter("stationId");
		JsonForList json = new JsonForList();
		if (StringUtils.isEmpty(stationId))
		{
			json.setCode("400");
			json.setMsg("stationId null");
			return json;
		}
		
		return chargerService.getChargerStatusByStationId(stationId);
	}
	/**
	 * @param httpUrl
	 *            :请求接口
	 * @param httpArg
	 *            :参数
	 * @return 返回结果
	 */
	public static String request(String httpUrl, String httpArg) {
	    BufferedReader reader = null;
	    String result = null;
	    StringBuffer sbf = new StringBuffer();
	    httpUrl = httpUrl + "?" + httpArg;

	    try {
	        URL url = new URL(httpUrl);
	        HttpURLConnection connection = (HttpURLConnection) url
	                .openConnection();
	        connection.setRequestMethod("GET");
	        // 填入apikey到HTTP header 
	        //wEyiqLGk3i5YUla5x3xuE7opDA2HUvip
	        //ab6227fdf59629bafc400b551e420550
	        connection.setRequestProperty("apikey",  "ab6227fdf59629bafc400b551e420550");
	        connection.connect();
	        InputStream is = connection.getInputStream();
	        reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
	        String strRead = null;
	        while ((strRead = reader.readLine()) != null) {
	            sbf.append(strRead);
	            sbf.append("\r\n");
	        }
	        reader.close();
	        result = sbf.toString();
	    } catch (Exception e) {
	        e.printStackTrace();
	    }
	    return result;
	}
	//通过电桩ID查询 站下属所有充电口的实时数据 
	//返回结果list： 已充电量、充电电压、充电电流、电池温度、开启时间、估计剩余时间、实际费用、枪口、SOC
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping("/getChargerStatusByChargerId")
	@ResponseBody  
	public JsonForList getChargerStatusByChargerId(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String charger_id = request.getParameter("charger_id");
		
		if(StringUtil.isBlank(charger_id)||StringUtil.isBlank(charger_id)){
			return new JsonForList(null,OmsConstant.ErrorCodeEnum.MissParam.value(), OmsConstant.ErrorCodeEnum.MissParam.desc());
		}
		OmsCharger query  = new OmsCharger();
		query.setCharger_id(charger_id);
		OmsCharger charger = omsChargerDao.findOneExample(query, null, null);
		if(charger == null || charger.getCharger_type() == null){
			return new JsonForList(null,OmsConstant.ErrorCodeEnum.ChargerQueryNull.value(), OmsConstant.ErrorCodeEnum.ChargerQueryNull.desc());
		}
		int charger_type = charger.getCharger_type();
		switch(charger_type){ // 设备电流类型:1--直流  2--交流 
		case 1:
			//先查询直流桩状态表
			String condition_d = " where charger_id ='" + charger_id + "' order by port_no"; // 去掉 group by charger_id
			List<OmsChargerStateDirect> directs= omsChargerStateDirectDao.findListByCondition(new OmsChargerStateDirect(), condition_d);
			for (int i = 0; i < directs.size(); i++){
				if (directs.get(i).getCharge_status() == 2){ // 0:空闲;1:预约;2 充电;3 故障;4:占用中(针对双枪单充等情况);5:刷卡中  8:离线
					// 如果直流桩在充电中,就通过redis查询对应的soc
					String key = directs.get(i).getCharger_id() + String.format("%02d", directs.get(i).getPort_no()) + "_status";
					String json = RedisClient.get(key);
					if (json != null) {
						ChargeDataUploadingVO charging_vo = JSON.parseObject(json, ChargeDataUploadingVO.class);
						directs.get(i).setCharger_kwh(Float.valueOf(charging_vo.getCharger_kwh()));
						directs.get(i).setCharger_minute(Float.valueOf(charging_vo.getCharger_time()));
						directs.get(i).setCharger_fee(Float.valueOf(charging_vo.getCharger_fee()));
						directs.get(i).setCharger_v(Float.valueOf(charging_vo.getCharger_v()));
						directs.get(i).setCharger_i(Float.valueOf(charging_vo.getCharger_i()));
						directs.get(i).setCharger_p(Float.valueOf(charging_vo.getCharger_p()));
						directs.get(i).setSoc(charging_vo.getSoc());
						directs.get(i).setRemaining_time(charging_vo.getRemaining_time());
					}
					
					String key_battery = charger_id + "0" + String.valueOf(directs.get(i).getPort_no()) + "_battery_3";
					List<String> list_redis_uploadBattery = RedisClient.getList(key_battery);
					float max_battery_temperature = 0.0f;
					if (list_redis_uploadBattery.size() > 0) {
						for (String str : list_redis_uploadBattery) {
							if (Float.compare(max_battery_temperature, Float.parseFloat(str)) > 0) {
								max_battery_temperature = Float.parseFloat(str);
							}
						}
						directs.get(i).setBattery_temperature(String.valueOf(max_battery_temperature));
					} else {
						directs.get(i).setBattery_temperature("0");
					}
				}
			}
			return new JsonForList(directs,OmsConstant.SuccessCodeEnum.SuccessCode.value(), OmsConstant.SuccessCodeEnum.SuccessCode.desc());
		case 2:
			String condition_a = " where charger_id ='" + charger_id + "' order by port_no"; // 去掉 group by charger_id
			List<OmsChargerStateAlternate> alternates= omsChargerStateAlternateDao.findListByCondition(new OmsChargerStateAlternate(), condition_a);
			for (int i = 0; i < alternates.size(); i++) {
				if (alternates.get(i).getCharge_status() == 2){ // 0:空闲;1:预约;2 充电;3 故障;4:占用中(针对双枪单充等情况);5:刷卡中  8:离线
					// 如果直流桩在充电中,就通过redis查询对应的soc
					String key = alternates.get(i).getCharger_id() + String.format("%02d", alternates.get(i).getPort_no()) + "_status";
					String json = RedisClient.get(key);
					if (json != null) {
						ChargeDataUploadingVO charging_vo = JSON.parseObject(json, ChargeDataUploadingVO.class);
						alternates.get(i).setCharger_kwh(Float.valueOf(charging_vo.getCharger_kwh()));
						alternates.get(i).setCharger_minute(Float.valueOf(charging_vo.getCharger_time()));
						alternates.get(i).setCharger_fee(Float.valueOf(charging_vo.getCharger_fee()));
						alternates.get(i).setCharger_v(Float.valueOf(charging_vo.getCharger_v()));
						alternates.get(i).setCharger_i(Float.valueOf(charging_vo.getCharger_i()));
						alternates.get(i).setCharger_p(Float.valueOf(charging_vo.getCharger_p()));
//						alternates.get(i).setSoc(charging_vo.getSoc()); //交流桩没有SOC
					}
				}
			}
			return new JsonForList(alternates,OmsConstant.SuccessCodeEnum.SuccessCode.value(), OmsConstant.SuccessCodeEnum.SuccessCode.desc());
		default:
			return new JsonForList(null,OmsConstant.ErrorCodeEnum.ParamValueError.value(), OmsConstant.ErrorCodeEnum.ParamValueError.desc());
		}
	}
	
	// 1.自营站点列表接口
	@SuppressWarnings("rawtypes")
	@RequestMapping("/getOfflineChargerList")
	@ResponseBody
	public JsonForList getOfflineChargerList(HttpServletRequest request, HttpServletResponse response) throws Exception {

		OmsChargerOfflineRecord record = new OmsChargerOfflineRecord();
		String charger_id = request.getParameter("charger_id");
		if(StringUtil.isNotBlank(charger_id)){
			record.setCharger_id(charger_id);
		}
		String detection_time = request.getParameter("detection_time");
		if(StringUtil.isNotBlank(detection_time)){
			record.setDetection_time(StringUtil.StrToDate(detection_time));//yyyyMMddHHmmss
		}
		
//		return chargerService.getChargerList(charger);
//		return "fghjm";
		List<OmsChargerOfflineRecord> list = omsChargerOfflineRecordDao.findExample(record, null, null, null, null);
		return new JsonForList(list, OmsConstant.SuccessCodeEnum.SuccessCode.value(), OmsConstant.SuccessCodeEnum.SuccessCode.desc());
	}	
	
}
